package com.sohoo.nio.mima.hander;

import java.net.SocketAddress;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.mina.core.service.IoHandler;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;

public class DemoHandler implements IoHandler {

	public void sessionCreated(IoSession session) throws Exception {
		SocketAddress remoteAddress = session.getRemoteAddress();
		DateFormat dateFormat = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]");
		Date now = new Date();
		System.out.println(remoteAddress.toString()+"---"+dateFormat.format(now)+"--进入了系统");
	}

	public void sessionOpened(IoSession session) throws Exception {
		// TODO Auto-generated method stub
		
	}

	public void sessionClosed(IoSession session) throws Exception {
		// TODO Auto-generated method stub
		
	}

	public void sessionIdle(IoSession session, IdleStatus status)
			throws Exception {
		// TODO Auto-generated method stub
		
	}

	public void exceptionCaught(IoSession session, Throwable cause)
			throws Exception {
		// TODO Auto-generated method stub
		
	}

	public void messageReceived(IoSession session, Object message)
			throws Exception {
		System.out.println(message);
	}

	public void messageSent(IoSession session, Object message) throws Exception {
		// TODO Auto-generated method stub
		
	}

	public void inputClosed(IoSession session) throws Exception {
		// TODO Auto-generated method stub
		
	}

}
